package com.neo.base.ListTest

object TestList {
  def main(args: Array[String]): Unit = {

    val oneTwoThree = List("one","Two","Three")
    oneTwoThree.foreach(println)
    for(i <- 0 to 2){
      println(oneTwoThree.apply(i))
    }
    oneTwoThree.foreach(arg => println(arg))



    println("********************************")
    consTest
  }

  //合并两个列表 追加
  def  consTest(): Unit = {
    val oneTwo = List(1,2)
    val threeFour = List(3,4)
    val oneTwoThreeFour = oneTwo  ::: threeFour  //合并两个列表
    println(oneTwoThreeFour)


     val oneOneTwo =  1::oneTwo //将新原始追加到List前端 :: 是oneTwo的方法
    println(oneOneTwo)
    val oneOneOneTwo =  oneOneTwo.::(1) //将新原始追加到List前端 :: 是oneTwo的方法
    println(oneOneOneTwo)




    //判断一个元素是否在List内
    val thrill = List("Hello","world","xiao","hui","ha","programer","ming")
    println(thrill.exists(s => s == "xiao"))

    println(thrill.contains("xiao"))


    //将元素个数为4的，过滤组成新的List
    println(thrill.filter(s => s.length ==4))

    //将元素个数追加4
    println(thrill.map(s => s + "4"))








  }
}
